Displays number of users online using a flat file (no database)

Just place this on the page where you want to see it. Be sure to have a users.txt file in the same directory CHMOD to 777

=======================================================

<?php

$config = array(
				user_time => time(),
				user_ip => $_SERVER['REMOTE_ADDR'];
				file_name => 'users.txt'
				);
				
				
$new_line = $config['user_ip'] . "|" . $config['user_time'] . "\r\n";

file_put_contents($config['file_name'], $new_line); //Write File

$online_file = file_get_contents($config['file_name']);
$online_file = explode("\r\n", $online_file);

foreach($online_file as $online_users)
{
	$users = explode("|", $online_users);
	if($users[1] >= time() - 300)
	{
		$online++;
	}
}

echo $online;


?>